import { isNumberStr } from "@/components/Form/utils";
export const onDefaultValueInput = (activeData: any, value: any) => {
  if (Array.isArray(activeData._config_.defaultValue)) {
    // 数组
    activeData._config_.defaultValue = value?.split(",").map((val: any) => (isNumberStr(val) ? +val : val));
  } else if (["true", "false"].indexOf(value) > -1) {
    // 布尔
    activeData._config_.defaultValue = JSON.parse(value);
  } else {
    // 字符串和数字
    activeData._config_.defaultValue = isNumberStr(value) ? +value : value;
  }
};
export const setDefaultValue = (val: any) => {
  if (Array.isArray(val)) {
    return val.join(",");
  }
  if (typeof val === "boolean") {
    return `${val}`;
  }
  return val;
};
export const addReg = (activeData: any) => {
  activeData._config_.regList.push({
    pattern: "",
    message: ""
  });
};
